<!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0, width=device-width"/>
        <meta name="format-detection" content="telephone=no"/>
        <title>发电回单详情</title>
        <link rel="stylesheet" type="text/css" href="../../css/api.css" />
        <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
        <link rel="stylesheet" type="text/css" href="../../css/common.css" />
        <link rel="stylesheet" type="text/css" href="css/billRevertDetail.css" />
    </head>
    <body>

    <!--下拉列表-->
		<script id="m-template" type="text/x-dot-template">
			{{ for(var i=0, len=it.length; i < len; i++) {}}
			<option value="{{=it[i].itemvalue}}">{{=it[i].itemname}}</option>
			{{ } }}
			</script>
			<!--下拉列表-->
		<script id="dict-template" type="text/x-dot-template">
			{{ for(var i=0, len=it.length; i < len; i++) {}}
			<option value="{{=it[i].itemname}}">{{=it[i].itemname}}</option>
			{{ } }}
		</script>


        <div id="wrap" style="display: none;">
            <form id="electricRevertForm">
                <!--停电回单begin-->
                <div id="eleBillRevertDivId" style="overflow:auto;">
                    <div class="cardDiv">
                        <div class="cardLabel">
                            <font color="red" >*</font>是否空跑：
                        </div>
                        <div class="cardCon">
                            <select id="isEmptyRunId" name="isEmptyRun" class="required" data-valid="required" data-error="请选择是否空跑！" value="" onchange="selectIsEmptyRun(this)">
                                <!--字典值（到站/未空跑：0、空跑：1、未出发：2）-->
                                <option value="">请选择</option>
                                <option value="0">到站发电/未空跑</option>
                                <option value="1">空跑</option>
                                <option value="2">未出发</option>
                            </select>
                        </div>
                    </div>
                      <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <font color="red" >*</font>油机类型：
                        </div>
                        <div class="cardCon">
                           <select id="oilTypeId"  value="" name="oilType" data-valid="" data-error="请选择油机型号！">
                                <option value="">------请选择------</option>
                                <option value="1">交流固定</option>
                                <option value="2">直流固定</option>
                                 <option value="3">交流移动</option>
                                 <option value="4">直流移动</option>
                            </select>
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <font color="red" >*</font>油机型号：
                        </div>
                        <div class="cardCon">
                            <input id="boardTypeId" name="boardType" class="required" data-valid="required" data-error="请填写油机型号！" type="text"  />
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <div class="cardLabelTop">
                                <font color="red" >*</font>油机数量&nbsp;&nbsp;&nbsp;&nbsp;
                            </div>
                            <div class="cardLabelDown">
                                (云南必填)(个)：
                            </div>
                        </div>
                        <div class="cardCon">
                            <input id="oillNumId" type="number" name="oillNum" data-valid="" data-error="请填写油机数量(云南必填)(个)！" />
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <div class="cardLabelTop">
                                <font color="red" >*</font>是否铁塔油机&nbsp;&nbsp;&nbsp;&nbsp;
                            </div>
                            <div class="cardLabelDown">
                                （江苏必填）：
                            </div>
                        </div>
                        <div class="cardCon">
                            <select id="towerOillId"  value="" name="towerOill" data-valid="" data-error="请选择是否铁塔油机(江苏必填)！">
                                <option value="">------请选择------</option>
                                <option value="1001">运营商油机</option>
                                <option value="1002">铁塔油机（含代维）</option>
                            </select>
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <div class="cardLabelTop">
                                <font color="red" >*</font>是否自动油机&nbsp;&nbsp;&nbsp;&nbsp;
                            </div>
                            <div class="cardLabelDown">
                                （广东必填）：
                            </div>
                        </div>
                        <div class="cardCon">
                            <select id="autoOillId"  value="" name="autoOill" data-valid="" data-error="请选择是否自动油机（广东必填）！">
                                <option value="">请选择</option>
                                <option value="1003">自动油机</option>
                                <option value="1004">非自动油机</option>
                            </select>
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabelDiv">
                            <div class="cardLabelTop">
                                <font color="red" >*</font>每小时油耗&nbsp;&nbsp;&nbsp;&nbsp;
                            </div>
                            <div class="cardLabelDown">
                                (广东、广西必填)(L)：
                            </div>
                        </div>
                        <div class="cardCon">
                            <input id="oillHourId" name="oillHour" type="number" data-valid="" data-error="请填写每小时油耗(广东、广西必填)(L)！"/>
                            <select  name="oillHour" style="display: none;" value="" data-valid="" data-error="请填写每小时油耗(广东、广西必填)(L)！">
                                <option value="">------请选择------</option>
                                <option value="2.75">2.75</option>
                                <option value="4.50">4.50</option>
                            </select>
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none;height:60px;">
                        <div class="cardLabelDiv">
                            <div class="cardLabelTop">
                                <font color="red" >*</font>每升汽油单价&nbsp;&nbsp;&nbsp;&nbsp;
                            </div>
                            <div class="cardLabelDown" style="height:40px;">
                                （北京、内蒙古、河南、云南、广西必填）:
                            </div>
                        </div>
                        <div class="cardCon" style="height:60px;">
                            <input id="oillPayId" name="oillPay" class="disabled" type="text"  disabled="disabled" />
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <font color="red" >*</font>功率：
                        </div>
                        <div class="cardCon">
                            <input id="workRateId" name="workRate" class="required" data-valid="required" data-error="请选择填写功率！" type="number"/>
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabelDiv">
                            <div class="cardLabelTop">
                                <font color="red" >*</font>
                                车辆往返里程&nbsp;&nbsp;&nbsp;&nbsp;
                            </div>
                            <div class="cardLabelDown">
                                （公里）：
                            </div>
                        </div>
                        <div class="cardCon">
                            <input id="vehicleMileageId" name="mileage" class="required" data-valid="required" data-error="请填写车辆往返里程(公里)！" type="number"/>
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabelDiv">
                            <div class="cardLabelTop">
                                <font color="red" >*</font>
                                发电人员到&nbsp;&nbsp;&nbsp;&nbsp;
                            </div>
                            <div class="cardLabelDown">
                                达时间：
                            </div>
                        </div>
                        <div class="cardCon">
                            <input id="arriveTimeId" name="arriveTime" class="required" data-valid="required" data-error="请填写发电人员到达时间！" type="datetime-local" style="line-height:40px;"  />
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <font color="red" >*</font>发电开始时间：
                        </div>
                        <div class="cardCon">
                            <input id="elecBeginTimeId" name="elecBeginTime" class="required" data-valid="required||checkEleBeginTime" data-error="请填写发电开始时间！||发电开始时间必须大于解挂时间！" type="datetime-local" style="line-height:40px;" />
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <font color="red" >*</font>发电结束时间：
                        </div>
                        <div class="cardCon">
                            <input id="elecEndTimeId" name="elecEndTime" class="required" data-valid="required||checkElecEndTime" data-error="请填写发电结束时间！||发电结束时间错误" type="datetime-local" style="line-height:40px;" />
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabelDiv">
                            <div class="cardLabelTop">
                                <font color="red" >*</font>
                                外市电恢复&nbsp;&nbsp;&nbsp;&nbsp;
                            </div>
                            <div class="cardLabelDown">
                                时间：
                            </div>
                        </div>
                        <div class="cardCon">
                            <input id="outerRecoverTimeId" name="outerRecoverTime" class="required" data-valid="required" data-error="请填写外市电恢复时间！" type="datetime-local" style="line-height:40px;"  />
                        </div>
                    </div>
                    <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <font color="red" >*</font>
                            断电原因：
                        </div>
                        <div class="cardCon">
                            <select id="electricityCausesId" name="outageCause" value=""  data-valid="required" data-error="请选择断电原因！" >
                                <option value="">请选择</option>
                                <option value="1">市电停电</option>
                                <option value="2">空开跳闸</option>
                                <option value="3">外电缺相</option>
                                <option value="4">电缆挖断</option>
                                <option value="5">业主拉电</option>
                                <option value="6">其它</option>
                            </select>
                        </div>
                    </div>

                    <div class="cardDiv" style="display: none">
                        <div class="cardLabel">
                            <font color="red" >*</font>
                            真实发电运营商：
                        </div>
                        <div class="cardCon">
                            <select id="realElecOperatorId" name="real_elec_operator" value=""  data-valid="required" data-error="请选择真实发电运营商！" >
                                <option value="">请选择</option>
                                <option value="1001">移动</option>
                                <option value="1002">联通</option>
                                <option value="1003">电信</option>
                                <option value="1001.1002">移动，联通</option>
	                            <option value="1001.1003">移动，电信</option>
                                <option value="1003.1002">联通，电信</option>
                                <option value="1001.1002.1003">移动，联通，电信</option>
                                <option value="1000">无</option>
                            </select>
                        </div>
                    </div>
                    <div id="isStandStaElecDivId" class="cardDiv" >
                        <div class="cardLabel">
                            <font color="red" >*</font>是否上站：
                        </div>
                        <div class="cardCon">
                            <select id="isStandStaElec" name="isUpStation" class="required" data-valid="required" data-error="请选择是否上战！" value="">
                                <option value="Y">是</option>
                                <option value="N">否</option>
                            </select>
                        </div>
                    </div>
                    <div class="cardDiv" >
                        <div class="cardLabel">
                            <font color="red" >*</font>是否免责：
                        </div>
                        <div class="cardCon">
                            <select id="isRefiefElec" name="isRelief" class="required" data-valid="required" data-error="请选择是否免责！"  value="" onchange="onSelRefief(this)">
                                <option value="">------请选择------</option>
                                <option value="Y">是</option>
                                <option value="N">否</option>
                            </select>
                        </div>
                    </div>
                    <div id="reliefTypeElecDivId" class="cardDiv" >
                        <div class="cardLabel">
                            <font color="red" >*</font>免责条款：
                        </div>
                        <div class="cardCon">
                            <select id="refiefTypeId" name="reliefType" class="required" data-valid="isRelief" data-error="请选择免责条款！"  value=""  >
                                <option value="">------请选择------</option>
                                <option value="1">免责条款1-不可抗力</option>
                                <option value="2">免责条款2-夜间免责</option>
                                <option value="3">免责条款3-客户原因</option>
                                <option value="4">免责条款4-免责站址</option>
                                <option value="5">免责条款5-其他免责</option>
                            </select>
                        </div>
                    </div>
                    <div id="reliefDealInfoElecDivId" class="cardTextareaDiv" >
                        <div class="cardTextareaLabel">
                            <font color="red" >*</font>免责具体原因：
                        </div>
                        <div class="cardTextareaCon">
                            <textarea name="reliefCause" class="required noborder" data-valid="isRelief" data-error="请填写免责具体原因！" rows="4" ></textarea>
                        </div>
                    </div>
                    <div class="cardDiv" >
                        <div class="cardLabel">
                            <font color="red" >*</font>故障原因：
                        </div>
                        <div class="cardCon">
                            <select id="stationCauseElecId" name="faultCouse" class="required" data-valid="required" data-error="请选择故障原因！" value=""  >
                                <option value="">------请选择------</option>
                                <option value="供电公司原因">供电公司原因</option>
                                <option value="铁塔原因">铁塔原因</option>
                                <option value="业主原因">业主原因</option>
                                <option value="其他原因">其他原因</option>
                            </select>
                        </div>
                    </div>

                    <div id='isshow' style="display: none">
					<div id="reliefTypeDivId" class="cardDiv">
						<div class="cardLabel">
							<font color="red" >*</font>故障名称：
						</div>
						<div class="cardCon">
							<input id="faultId" name="faultname" type="text"  value="" disabled="disabled" style="height:35px; line-height:35px;">
						</div>
					</div>
					<div id="reliefTypeDivId" class="cardDiv">
						<div class="cardLabel">
							<font color="red" >*</font>原因细分：
						</div>
						<div class="cardCon">
							<select id="causeid" name='faultid' class="required" data-valid="required" data-error="请选择原因细分！"  value="" onchange="onSelBigData(this)" >
								<option value="">------请选择------</option>
							</select>
								<input id='causetxt_id' type="text"  value="暂未细分原因" disabled="disabled" style="height:35px; line-height:35px;display: none;">
						</div>
					</div>
					<div class="cardTextareaDiv" style="margin-bottom:20px;">
						<div class="cardTextareaLabel">
							<font color="red" >*</font>
							推荐方案：
						</div>
						<div class="cardTextareaCon">
							<textarea id='commend_id' rows="8" class="noborder"  disabled="disabled"></textarea>
						</div>
					</div>
					<div id="reliefTypeDivId" class="cardDiv">
						<div class="cardLabel">
							<font color="red" >*</font>具体措施：
						</div>
						<div class="cardCon">
							<select id="dealway_id" name='dealid'  class="required" data-valid="required" data-error="请选择具体措施！"  value=""  onchange="onSelBigDetail(this)">
								<option value="">------请选择------</option>
							</select>
							<input  id='dealtxt_id' type="text"  value="暂无具体措施" disabled="disabled" style="height:35px; line-height:35px;display: none;">
						</div>
					</div>
					</div>

                    <div class="cardDiv" >
                        <div class="cardLabel">
                            <font color="red" >*</font>修复时间：
                        </div>
                        <div class="cardCon">
                            <input id="elecRecoverTimeId" name="recoveryTime" class="required" data-valid="required||checkRecoveryTime" data-error="请填写修复时间！||修复时间不能大于当前时间!" type="datetime-local" style="line-height:40px;"/>
                        </div>
                    </div>
                    <div class="cardTextareaDiv" style="margin-bottom:20px;">
                        <div class="cardTextareaLabel">
                            <font color="red" >*</font>
                            处理方法：
                        </div>
                        <div class="cardTextareaCon">
                            <textarea id="causeDealInfoElecId" name="handlerResult" rows="8" class="noborder required" data-valid="required||checkChineseCount" data-error="请填写处理方法！||处理方法内容不符合规范，必须包含4个文字"></textarea>
                        </div>
                    </div>
                </div>
                <div id="hiddenForm" style="display: none">
                    <script id="hiddenParam-template" type="text/x-dot-template">
                        <input name="billId" type="hidden" value="{{=it.billid}}"/>
                        <input name="billSn" type="hidden" value="{{=it.billsn}}"/>
                        <input name="taskId" type="hidden" value="{{=it.taskid}}"/>
                        <input name="billStatus" type="hidden" value="1"/>
                    </script>
                </div>
                <!--停电回单end-->
                <footer style="height:50px;">
                    <div class="cardButtonDiv">
                        <button class="billRevertCancelBtn"  onclick="api.closeWin()">
                            取消
                        </button>
                        <button id="submitBtn" class="billRevertOkBtn">
                            确定
                        </button>
                    </div>
                </footer>
            </form>
        </div>
    </body>
    <script src="../../script/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="../../script/api.js"></script>
    <script type="text/javascript" src="../../script/aui.js"></script>
    <script type="text/javascript" src="../../script/doT.min.js"></script>
    <script type="text/javascript" src="../../script/common.js"></script>
    <script type="text/javascript" src="../../script/config.js"></script>
	<script type="text/javascript" src="../../script/request.js"></script>
    <script type="text/javascript" src="../../script/gongdan.js"></script>
    <script type="text/javascript" src="../../script/client.api.js"></script>
    <script type="text/javascript" src="../../script/debug.js"></script>
    <script type="text/javascript" src="../../script/jquery-validate.js"></script>
    <script type="text/javascript" src="script/billForm.js"></script>
    <!--<script type="text/javascript" src="script/validate-rules.js"></script>-->
    <script>
        var billModel;
        var provinceid;
        var bigData;
        apiready = function() {

            api.setStatusBarStyle({
                style : 'light'
            });
           provinceid=$api.getStorage('provinceid');
			billModel = $api.getStorage('billModel');
			//		$('#wrap')
			if(billModel.st_provinceid=='广东分公司'&&("设备告警工单"==billModel.businesstype)){
			$('#isshow').show();
				getBigData();
			}else{
			$('#causeid').removeClass('required');
			$('#dealway_id').removeClass('required');
			$('#wrap').show();
			if("REVERT"==api.pageParam.billStatus&&(billModel.rev_is_empty_run==null||billModel.rev_is_empty_run==''
				||billModel.rev_is_empty_run=='1'||billModel.rev_is_empty_run=='2')){
				$('#isEmptyRunId').parents('.cardDiv').hide();
				$('#isEmptyRunId').removeClass('required');
				$('#oilTypeId').removeClass('required');
				$('#boardTypeId').removeClass('required');
				$('#oillNumId').removeClass('required');
				$('#workRateId').removeClass('required');
				$('#vehicleMileageId').removeClass('required');
				$('#arriveTimeId').removeClass('required');
				$('#elecBeginTimeId').removeClass('required');
				$('#elecEndTimeId').removeClass('required');
				$('#outerRecoverTimeId').removeClass('required');

			}
			}

            initDict();
            initRelief();
            initSpecicalUnit();
            var billForm = new BillForm($('form'), $('#submitBtn'), $client.genelecRevertBill);
            billForm.init();
            renderTemp('hiddenForm', 'hiddenParam-template', billModel);
            api.pageParam.billRevert = true;
            //＊修复ios无法显示时间问题
            $('[name=recoveryTime]').focus(function() {
                $(this).css('border', 'red');
            });
        };

        function getBigData(){
		api.showProgress({
				title : '加载中...'
			});
		$client.getRevertCauseDetail({
				billsn : billModel.billsn
			}, function(ret, err) {
				if (ret) {
					//          api.hideProgress();
					if (ret.success) {
						var bigList = ret.list;
							if(bigList!=null&&bigList.length>0){
						$('#faultId').val(bigList[0].fault_name);
						for (var i = 0, size = bigList.length; i < size; i++) {
							$('<option>').text(bigList[i].name).val(bigList[i].id).appendTo('#causeid');
						}
						$('<option>').text('其他').val('-1').appendTo('#causeid');
						}else{
						$('#causeid').removeClass('required');
						$('#dealway_id').removeClass('required');
						$('#causeid').hide();
						$('#dealway_id').hide();
						$('#causetxt_id').show();
						$('#dealtxt_id').show();
						}
						$('#wrap').show();
					} else {
						api.toast({
							msg : ret.data_info
						});
					}
				} else {
					api.toast({
						msg : '获取工单详情出错!'
					});
				}
				api.hideProgress();
			});
		}

		function onSelBigData(obj) {
			var str='';
			bigData=$(obj).find("option:selected").text();
			if($(obj).val()!=-1){
			$('#dealway_id').attr('disabled',false);
			$('#causeDealInfoElecId').val('');
			$client.getRevertDeailWay({
				id : $(obj).val()
			}, function(ret, err) {
				if (ret) {
					//          api.hideProgress();
					if (ret.success) {
						$('#dealway_id').empty();
						var detailList = ret.list;
						$('<option>').text('------请选择------').val('').appendTo('#dealway_id');
						for (var i = 0, size = detailList.length; i < size; i++) {
							$('<option>').text(detailList[i].deal_name).val(detailList[i].id).appendTo('#dealway_id');
							str+=(i+1)+'、'+detailList[i].deal_name+"\n"
						}
						$('<option>').text('其他').val('-1').appendTo('#dealway_id');
						$('#commend_id').html(str);
					} else {
						api.toast({
							msg : ret.data_info
						});
					}
				} else {
					api.toast({
						msg : '获取工单详情出错!'
					});
				}
			});
			}else{
			$('#dealway_id').empty();
			$('#dealway_id').attr('disabled',true);
			$('<option>').text('其他').val('-1').appendTo('#dealway_id');
			$('#commend_id').html('');
			$('#causeDealInfoElecId').val('');
			}
		}

		  //故障类型选择触发事件
		function onSelBigDetail(obj) {
//		$("#ddlregtype").find("option:selected").text()
			var val = $(obj).find("option:selected").text();
			if (val == '其他') {
				$('#causeDealInfoElecId').val('');
			}else{
			$('#causeDealInfoElecId').val('原因细分：'+bigData+'\n具体措施：'+val);
			}
		}

        function initRelief() {
            var st_ifrelief = billModel.st_ifrelief;
            var st_ifnight_mz = billModel.st_ifnight_mz;
            var recoveryTime = billModel.recovery_time;
            var isrecovery = billModel.alarm_isrecovery;
            if (recoveryTime != null) {
				recoveryTime = recoveryTime.replace(" ", "T");
			}
            if (st_ifrelief == "是" || st_ifnight_mz == "是") {
                $('[name=isRelief]').val("Y");
                if (st_ifrelief == "是") {
                    $('[name=reliefType]').val('4');
                } else if (st_ifnight_mz == "是") {
                    $('[name=reliefType]').val('2');
                }
            }
            $('#oillPayId').val( typeof (billModel) != 'undefined' ? billModel.payorder : 0);

            if ("人工受单" != billModel.businesstype) {//故障
				if (isrecovery != null && isrecovery == 'Y' && recoveryTime != null) {
					$api.byId('elecRecoverTimeId').value = recoveryTime;
				} else {
					$api.byId('elecRecoverTimeId').value = getNowFormatDate();
				}
			} else {//人工受单
				$api.byId('elecRecoverTimeId').value = getNowFormatDate();
			}
        }

        function initDict() {
			var disclaimerList = $api.getStorage("disclaimerList");	//免责条款
			var elecCauseList = $api.getStorage("elecCauseList");	//故障原因
			var oilTypeList = $api.getStorage("oilTypeList");	//油机类型
			var towerOilList = $api.getStorage("towerOilList");	//油机类型
			//免责条款
			if (disclaimerList != null && disclaimerList.length > 0) {
				$('#refiefTypeId').empty();
				$('<option>').text('请选择').val('').appendTo('#refiefTypeId');
				renderTemp('refiefTypeId', 'm-template', disclaimerList, true);
			}

			if (elecCauseList != null && elecCauseList.length > 0) {
				$('#stationCauseElecId').empty();
				$('<option>').text('请选择').val('').appendTo('#stationCauseElecId');
				renderTemp('stationCauseElecId', 'dict-template', elecCauseList, true);
			}

			if (oilTypeList != null && oilTypeList.length > 0) {
				$('#oilTypeId').empty();
				$('<option>').text('请选择').val('').appendTo('#oilTypeId');
				renderTemp('oilTypeId', 'm-template', oilTypeList, true);
			}

			if (towerOilList != null && towerOilList.length > 0) {
				$('#towerOillId').empty();
				$('<option>').text('请选择').val('').appendTo('#towerOillId');
				renderTemp('towerOillId', 'm-template', towerOilList, true);
			}
			}

        function getNowFormatDate() {
			var date = new Date();
			var seperator1 = "-";
			var seperator2 = ":";
			var month = date.getMonth() + 1;
			var strDate = date.getDate();
			var hour = date.getHours();
			var min = date.getMinutes();
			var s = date.getSeconds();
			if (month >= 1 && month <= 9) {
				month = "0" + month;
			}
			if (strDate >= 0 && strDate <= 9) {
				strDate = "0" + strDate;
			}
			if (hour >= 0 && hour <= 9) {
				hour = "0" + hour;
			}
			if (min >= 0 && min <= 9) {
				min = "0" + min;
			}
			if (s >= 0 && s <= 9) {
				s = "0" + s;
			}
			var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + "T" + hour + seperator2 + min + seperator2 + s;
			return currentdate;
		}

        function selectIsEmptyRun(thx) {
            var val = parseInt($(thx).val());
            var hideList = ['#oilTypeId','#boardTypeId', '#workRateId', '#elecBeginTimeId', '#elecEndTimeId', '#arriveTimeId', '#outerRecoverTimeId', '#vehicleMileageId', '#electricityCausesId', '#realElecOperatorId','#oillNumId', '#towerOillId', '#autoOillId', '#oillHourId', '#oillPayId'];
            switch(val) {
                case 0 :
                    //                  $('#isStandStaElec').val('Y').attr('disabled', true);
                    $('#isStandStaElec').val('Y');
                    for (var i = 0, size = hideList.length; i < size; i++) {
                        var $target = $(hideList[i]).removeClass('required');
                        var valid = $target.attr('data-valid');
                        if ($target.attr('data-valid') != '' && !$target.attr('disabled')) {
                            $target.addClass('required');
                        }
                        $target.parents('.cardDiv').show();
                    }
                    $('#elecBeginTimeId,#elecEndTimeId,#arriveTimeId,#outerRecoverTimeId,#elecRecoverTimeId').focus(function() {
                        $(this).css('border', 'red');
                    });
                    break;
                case 1 :
                case 2 :
                default :
                    //                  $('#isStandStaElec').val('N').attr('disabled', true);
                    $('#isStandStaElec').val('N');
                    for (var i = 0, size = hideList.length; i < size; i++) {
                        var $target = $(hideList[i]).removeClass('required');
                        $target.parents('.cardDiv').hide();
                    }
                    break;
            }
        }

        function initSpecicalUnit() {
            var userUnitData = $api.getStorage('userUnitData');
            //以下为测试数据
            //          var userUnitData = {
            //              "i" : "0000017",
            //              "n" : "中国铁塔股份有限公司",
            //              "l" : 2,
            //              "c" : [{
            //                  "i" : "0098356",
            //                  "n" : "广西分公司",
            //                  "l" : 3,
            //                  "c" : [{
            //                      "i" : "0099939",
            //                      "n" : "湖南分公司本部",
            //                      "l" : 4,
            //                      "c" : []
            //                  }]
            //              }]
            //          };
            //云南(0098356)，江苏(0001944)，广东(0001934），广西(0098364)，北京(0001935)、内蒙古(0098372)、河南(0090330)
            var specialUnitList = [{
                id : '0098356',
                name : '云南',
                requiredList : ['oillNum', 'oillPay']
            }, {
                id : '0001944',
                name : '江苏',
                requiredList : ['towerOill']
            }, {
                id : '0001934',
                name : '广东',
                requiredList : ['autoOill', 'oillHour']
            }, {
                id : '0098364',
                name : '广西',
                requiredList : ['oillHour', 'oillPay']
            }, {
                id : '0098372',
                name : '内蒙古',
                requiredList : ['oillPay']
            }, {
                id : '0001935',
                name : '北京',
                requiredList : ['oillPay']
            }, {
                id : '0090330',
                name : '河南',
                requiredList : ['oillPay']
            }];
            var prov = userUnitData.c[0];
            //默认以第一个省为判定条件
            var provId = prov.i;
            for (var i = 0, size = specialUnitList.length; i < size; i++) {
                var specialUnit = specialUnitList[i];
                if (specialUnitList[i].id == provId) {
                    for (var j = 0; j < specialUnit.requiredList.length; j++) {
                        if (specialUnit.id == '0098364') {
                            $('name[' + specialUnit.requiredList[j] + ']:eq(0)').hide().removeClass('required').siblings().show().attr('data-valid', 'isEmptyRun').addClass('required');
                            continue;
                        } else {
                            $('#' + specialUnit.requiredList[j] + 'Id').attr('data-valid', 'isEmptyRun');
                        }
                    }
                    break;
                }
            }
        }




        function onSelRefief(self) {
            var wrapper = $('form [name=reliefType],form [name=reliefCause]').parents('[id^=relief]');
            $(self).val() == 'Y' ? wrapper.show() : wrapper.hide();
        }
    </script>
</html>
